// Author: wsfuyibing <682805@qq.com>
// Date: 2025-06-11

package responses

import (
	"server/app/http/models"
	"server/app/kind"
)

// OrderItemResponse
// 订单条目.
type OrderItemResponse struct {
	Id            int64
	OrderId       int64
	OrderKind     kind.OrderKind
	OrderKindText string
	Locked        kind.LockedState
	LockedText    string
	Amount        kind.Balance
	Discount      kind.Balance
	Price         kind.Balance
	Quantity      kind.GoodsStock
	QuantityReset bool
	ResourceId    int64
	Unit          kind.GoodsUnit
	UnitText      string
	Name          string
	Image         string
	Page          string
}

// With
// 数据绑定.
func (o *OrderItemResponse) With(m *models.OrderItem) *OrderItemResponse {
	o.Id = m.Id
	o.OrderId = m.OrderId
	o.OrderKind = m.OrderKind
	o.OrderKindText = m.OrderKind.Text()
	o.Locked = m.Locked
	o.LockedText = m.Locked.Text()
	o.Amount = m.Amount
	o.Discount = m.Discount
	o.Price = m.Price
	o.Quantity = m.Quantity
	o.QuantityReset = m.QuantityReset.IsYes()
	o.ResourceId = m.ResourceId
	o.Unit = m.Unit
	o.UnitText = m.Unit.Text()
	o.Name = m.Name
	o.Image = m.Image
	o.Page = m.OrderKind.Page()
	return o
}
